<!DOCTYPE html>
<!--suppress ThymeleafVariablesResolveInspection -->
<!-- supperss ALL -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>问答详情</title>
    <meta name="keywords" content="牙疼,牙疼导致耳朵疼,牙疼导致耳朵疼的原因,有贝口腔网,口腔问答,口腔问题">
    <meta name="description" content="牙疼怎么导致耳朵疼了？,有贝口腔网为用户提供专业的口腔资讯，口腔知识，口腔问题等综合服务型网站">
    <link rel="stylesheet" href="./yb_system_css/reset.css">
    <link rel="stylesheet" href="./yb_system_css/commone.css">
    <link rel="stylesheet" href="./yb_system_css/commthree.css">
    <link rel="stylesheet" href="./yb_system_css/pinglun.css">
    <link rel="stylesheet" media="screen and (min-width:481px)" href="./yb_system_css/qadetail.css">
    <link rel="stylesheet" media="screen and (max-width:480px)" href="./yb_system_css/qadetail(1).css">
    <script src="./yb_system_js/hm.js"></script>
    <script type="text/javascript">
        var basePath = "/";
    </script>
    <script src="./yb_system_js/common.js"></script>
    <script src="./yb_system_js/jquery-3.5.1.min.js"></script>
    <script src="./yb_system_js/footfixed.js"></script>
    <script src="./yb_system_js/qadetail.js"></script>
    <script src="./yb_system_js/condetail.js"></script>
    <script src="./yb_system_js/wangEditor.js"></script>
    <script src="./yb_system_js/layer.js"></script>
</head>

<body>
<div class="content">

    <div th:replace="public :: header"></div>

    <div class="main-tab">
        <div class="max-width">
            <ul class="main-tab-ul">
                <li><a th:href="@{/askAnswer}" target="_self">今日热门</a></li>
                <li th:each="thTypeList,typeState:${thTypeList}" th:if="${thTypeList.type == 20 && typeState.count <= 10}">
                    <a class="main-tab-active"  th:if="${typeId == thTypeList.id}" th:href="@{/answerType(id=${thTypeList.id})}" target="_self" th:text="${thTypeList.name}"></a>
                    <a th:if="${typeId != thTypeList.id}" th:href="@{/answerType(id=${thTypeList.id})}" target="_self" th:text="${thTypeList.name}"></a>
                </li>
                <li class="tab-more-list">
                    <a href="javascript:;" target="_self">
                        <span>更多</span>
                        <img class="arrow-bottom" src="./yb_system_picture/arrow-bttom.png" alt="有贝口腔网">
                    </a>
                    <div>
                        <ul>
                            <li th:each="thTypeList,typeState:${thTypeList}" th:if="${thTypeList.type==20 && typeState.count > 10}">
                                <a class="main-tab-active"  th:if="${typeId == thTypeList.id}" th:href="@{/answerType(id=${thTypeList.id})}" target="_self" th:text="${thTypeList.name}"></a>
                                <a th:if="${typeId != thTypeList.id}" th:href="@{/answerType(id=${thTypeList.id})}" target="_self" th:text="${thTypeList.name}"></a>
                            </li>
                        </ul>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <div class="content-main">
        <input type="hidden" id="no" th:value="${time}">
        <input type="hidden" id="answerId" th:value="${detaiObject.id}">
        <input type="hidden" id="collectType" value="20">
        <div class="box-bg-shadow">
            <div class="qa-top">
                <a class="qa-type" th:href="@{/answerType(id=${detaiObject.typeId})}" th:text="${detaiObject.typeName}"></a>
                <a class="ansower-type" th:href="@{/userHomepage(id=${detaiObject.userId})}">
                    <img th:if="${detaiObject.userPhotoPath == null}" src="./yb_system_picture/user_Default.png" alt="有贝口腔网">
                    <img th:if="${detaiObject.userPhotoPath != null}" th:src="${detaiObject.userPhotoPath}">
                    <span th:text="${detaiObject.nickname}"></span>
                </a>
                <a class="please-ansower" href="javascript:;"> 遇到下面问题，需要你帮忙解答</a>
            </div>
            <div class="qa-title" th:text="${detaiObject.question}"></div>
            <div class="qa-info-share">
                <div class="qa-info">
                    <a href="javascript:;" class="huida-num">
                        <img src="./yb_system_picture/icon_News.png" alt="有贝口腔网">
                        <span th:text="${detaiObject.answerNum+'个回答'}"></span>
                    </a>
                    <a href="javascript:;" class="thumbs-up">
                        <img src="./yb_system_picture/icon_Browse.png" alt="有贝口腔网">
                        <span th:text="${detaiObject.readNum+'阅读'}"></span>
                    </a>
                    <a href="javascript:;" class="conllection" onclick="myCollect(this)">
                        <img src="./yb_system_picture/shoucang1.png" alt="有贝口腔网">
                        <span id="collectType20" th:text="'收藏问题('+${detaiObject.collectNum+')'}"></span>
                    </a>
                    <span class="time" th:text="${#dates.format(detaiObject.publishTime,'yyyy-MM-dd')}"></span>
                </div>
                <div class="bshare-custom icon-medium">
                    <div class="bsPromo bsPromo2"></div>
                    <a title="分享到QQ空间" class="bshare-qzone"></a>
                    <a title="分享到QQ好友" class="bshare-qqim" href="javascript:void(0);"></a>
                    <a title="分享到微信" class="bshare-weixin" href="javascript:void(0);"></a>
                    <a title="分享到新浪微博" class="bshare-sinaminiblog"></a>
                    <a title="分享到腾讯微博" class="bshare-qqmb"></a>
                    <a title="分享到i贴吧" class="bshare-itieba" href="javascript:void(0);"></a>
                    <a title="更多平台" class="bshare-more bshare-more-icon more-style-addthis"></a>
                    <span class="BSHARE_COUNT bshare-share-count" style="float: none;">0</span>
                </div>
                <script type="text/javascript" charset="utf-8" src="./yb_system_js/buttonLite.js"></script>
                <script type="text/javascript" charset="utf-8" src="./yb_system_js/bshareC0.js"></script>
            </div>
            <div class="editor-div">

                <div id="editor">
                    <p class="tip-text">我来回答，我有更好的回答</p>
                </div>

                <div class="edditor-bottom">
                    <div>字数 <span class="length">0</span></div>
                    <div class="sub-btn" id="answerId" th:value="${detaiObject.id}">发表回答</div>
                </div>

            </div>
            <div class="qa-info-list">
                <div class="qa-list-top">
                    <span th:if="${listResponseEntity !=null}"><em th:text="${listResponseEntity.size()}"></em>&nbsp;个回答</span>
                    <span th:if="${listResponseEntity ==null}"><em>0</em>&nbsp;个回答</span>
                </div>
                <div id="myContent" th:if="${listResponseEntity !=null}">
                    <div class="qa-list-item" th:each="listResponseEntity:${listResponseEntity}">
                        <div class="list-item-user">
                            <div class="user-img-name">
                                <a class="user-img" th:href="@{/userHomepage(id=${listResponseEntity.userId})}" target="_blank">
                                    <img th:if="${listResponseEntity.userMemberVO.photoPath == null}" src="./yb_system_picture/user_Default.png">
                                    <img th:if="${listResponseEntity.userMemberVO.photoPath != null}" th:src="${listResponseEntity.userMemberVO.photoPath}">
                                </a>
                                <div class="qa-name-time">
                                    <a th:href="@{/userHomepage(id=${listResponseEntity.userId})}" target="_blank" th:text="'有贝口腔网   '+${listResponseEntity.userMemberVO.nickname}"></a>
                                    <span th:text="${listResponseEntity.publishTime}"></span>
                                </div>
                            </div>
                        </div>
                        <div class="list-item-content" th:utext="${listResponseEntity.content}"><br>
                        </p></div>
                        <div class="show-all" style="display: none;">
                            <div class="bg-div"></div>
                            <span>展开全部</span>
                        </div>
                        <div class="qa-info">
                            <a href="javascript:;" class="thumbs-up" onclick="addOption(this,1);" th:id="${listResponseEntity.id}">
                                <img src="./yb_system_picture/icon_Like.png" alt="有贝口腔网">
                                <span id="qaReplyLikeCount253" th:text="${listResponseEntity.raiseNum+'点赞'}"></span>
                            </a>
                            <a href="javascript:;" class="thumbs-down" onclick="addOption(this,0)" th:id="${listResponseEntity.id}">
                                <img src="./yb_system_picture/icon_Like.png" alt="有贝口腔网">
                                <span id="qaReplyStepCount253" th:text="${listResponseEntity.downNum+'踩'}"></span>
                            </a>
                            <a href="javascript:;" class="comment-on five" onclick="commentInit(this)" th:id="${listResponseEntity.id}">
                                <img src="./yb_system_picture/icon_News.png" alt="有贝口腔网">
                                <span th:id="commentCount+${listResponseEntity.getId()}" th:text="${listResponseEntity.commentNum+'评论'}"></span>
                            </a>
                            <span th:text="${listResponseEntity.publishTime}"></span>
                        </div>
                        <div class="pinglun" style="display: none;">
                            <div class="publish-discuss">
                                <div class="user-logo">
                                    <!--评论就获取登录用户数据-->
                                    <a th:href="@{/userHomepage(id=${listResponseEntity.userId})}">
                                        <img src="./yb_system_picture/user_Default.png">
                                    </a>
                                </div>
                                <div class="discuss-input">
                                    <textarea placeholder="写下您的评论..." class="textarea" th:id="commentContent+${listResponseEntity.getId()}"></textarea>
                                    <div class="answer-div">
                                        <span class="answer-btn" th:id="${listResponseEntity.getId()}" onclick="btdAddComment(this)">评论</span>
                                    </div>
                                </div>
                            </div>
                            <div class="discuss-box" th:id="commentList+${listResponseEntity.getId()}">

                            </div>
                            <div class="show-more" onclick="moreCommentlist(this)" th:id="${listResponseEntity.getId()}">查看更多评论</div>
                        </div>
                    </div>
                </div>

                <div class="more-content">
                    <div class="load-more" style="display:none">
                        <img src="./yb_system_picture/load-more.gif" alt="有贝口腔网">
                        <span>加载中</span>
                    </div>
                </div>
            </div>
        </div>

        <div class="aside-left">

            <div class="wonderful-top">
                <div class="wonderful-top-title">
                    <img src="./yb_system_picture/Linkeddatabases.png" alt="有贝口腔网">
                    <span>相关问题</span>
                </div>
                <div class="aside-qa-list" th:each="orderList:${orderList}">
                    <a th:href="@{/askAnswerDetail(id=${orderList.id})}">
                        <span class="aside-qa-title" th:text="${orderList.question}"></span>
                    </a>
                    <a th:href="@{/askAnswerDetail(id=${orderList.id})}">
                        <span class="aside-qa-ansower" th:text="${orderList.answerNum+'个回答'}"></span>
                    </a>
                </div>
            </div>

            <div class="wonderful-top">
                <div class="wonderful-top-title">
                    <span>大家都在问</span>
                </div>
                <div class="wonderful-ansewer-list">
                    <!--后台查询五条数据进行展示-->
                    <div class="ansewer-list-item" th:each="orderList1:${orderList1}">
                        <span class="pink-bg">1</span>
                        <div>
                            <a target="_blank" class="ansewer-list-title" th:href="@{/askAnswerDetail(id=1)}" th:text="${orderList1.question}"></a>
                            <div class="ansewer-list-info">
                                <a target="_blank" th:href="@{/askAnswerDetail(id=1)}">
                                    <span class="ansewer-list-info-ansewer">回答</span>
                                </a>
                                <a target="_blank" th:href="@{/askAnswerDetail(id=1)}" th:text="${orderList1.answerNum+'个回答'}"></a>
                                <span class="dotted"></span>
                                <a target="_blank" th:href="@{/askAnswerDetail(id=1)}" th:text="${orderList1.readNum+'阅读'}"></a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div th:replace="public::footer"></div>

    <script>
        var _hmt = _hmt || [];
        (function () {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?4245936cbef31e434e2b387b56dfd7d8";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>


</div>

<script type="text/javascript">

    $(function(){
        //编辑器
        var E = window.wangEditor;
        var editor = new E('#editor');

        // 自定义菜单配置
        editor.customConfig.menus = [
            'head',  // 标题
            'bold',  // 粗体
            'fontSize',  // 字号
            'fontName',  // 字体
            'italic',  // 斜体
            'underline',  // 下划线
            'strikeThrough',  // 删除线
            'foreColor',  // 文字颜色
            'backColor',  // 背景颜色
            'link',  // 插入链接
            'list',  // 列表
            'justify',  // 对齐方式
            'quote',  // 引用
            'emoticon',  // 表情
            'image',  // 插入图片
            'table',  // 表格
            'video',  // 插入视频
            'code',  // 插入代码
            'undo',  // 撤销
            'redo'  // 重复
        ];

        editor.customConfig.linkImgCheck = function (src) {
            console.log("图片："+src) // 图片的链接
            return true // 返回 true 表示校验成功
        }

        // 将图片大小限制为 3M
        editor.customConfig.uploadImgMaxSize = 1 * 1024 * 1024;
        // 限制一次最多上传 2 张图片
        editor.customConfig.uploadImgMaxLength =2;
        //开启debug模式
        editor.customConfig.debug = true;
        // 关闭粘贴内容中的样式
        editor.customConfig.pasteFilterStyle = false;
        // 忽略粘贴内容中的图片
        editor.customConfig.pasteIgnoreImg = true;

        // 使用 base64 保存图片
        //editor.customConfig.uploadImgShowBase64 = true;

        editor.customConfig.uploadFileName = "uploadFile";
        // 配置服务器端地址 upload:上传图片地址
        editor.customConfig.uploadImgServer = 'http://localhost:9998/upload';
        editor.customConfig.debug = true;
        //自定义上传图片事件

        editor.customConfig.uploadImgHooks = {
            error: function (xhr, editor) {
                console.log("上传出错");
            },
            timeout: function (xhr, editor) {
                console.log("上传超时");
            },
            customInsert: function (insertImg, result, editor) {
                // 图片上传并返回结果，自定义插入图片的事件（而不是编辑器自动插入图片！！！）
                var url = result.url;
                //不加http显示不出（返回的数据格式必须是json字符串{url:xxx}）
                insertImg("http://"+url)
            }
        };

        //去除复制带来的标签代码
        editor.customConfig.pasteTextHandle = function (content) {
            return delHtmlTag(content);
        }

        //获取输入的字数
        editor.customConfig.onchange = function () {
            var articallength = editor.txt.text().length;
            $(".length").text(articallength);
        }

        //去除文章提示
        editor.customConfig.onfocus = function () {
            $(".tip-text").remove();
        }

        editor.create();

        $(".sub-btn").click(function () {

            if (!isLogin()) {//进行登录
                loginPop();
                return;
            }

            $(".tip-text").remove();

            var content = editor.txt.text();
            if (content == '' || content.length < 10) {
                alert("请输入回答10以上个字符");
                return false;
            }
            addReply(editor.txt.html());//回复
        });

    });

    function addReply(content) {
        console.log("问题详情发表回答（内容）：",content);
        if (isBlank(content)) {
            alert("请输入回答内容");
            return;
        }

        var answerId=$("#answerId").val();
        var no = $("#no").val();
        var data = {};
        data["no"] = no;
        data["content"] = content;
        data["answerId"]=answerId;
        $.ajax({
            type: "POST",
            url: basePath + "qa/addReply",
            data: data,
            success: function (data) {
                if (data.success) {
                    alert("恭喜你，回答成功，待审核中");
                    editor.txt.html('');
                } else {
                    alert(data.msg);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("链接错误,请联系管理员");
            }
        });
    }


    //===评论事件
    $(function () {
        qaPinglunInitEv();
        initOverflow();
    })

    function qaPinglunInitEv() {
        $(".asdn").hide();
        $(".show-all").unbind("click");
        $(".show-all").click(function () {
            $(".asdn").show();
            $(this).hide();
        })


        $(".pinglun").hide();
        $(".five").unbind("click");
        $(".five").click(function () {//点击评论展开评论内容
            if ($(this).parent().next().is(':hidden')) {//如果是隐藏就就显示
                $(".pinglun").hide();//先隐藏其他已展开的评论
                $(this).parent().next().show();//再次展开自己
            } else {//因此
                $(this).parent().next().hide();
            }
        });
    }

    function initOverflow() {
        // 太长隐藏点击展开
        $(".show-all").hide();
        $(".list-item-content").each(function (i, dom) {
            if ($(this).height() > 300) {
                $(this).next().show();
                $(this).addClass("overflow-content");
            } else {
                $(this).next().hide();
                $(this).removeClass("overflow-content");
            }
        })
        $(".show-all").click(function () {
            $(this).prev(".list-item-content").removeClass("overflow-content");
            $(this).hide();
        })

        //问题背景隐藏
        $(".shou-all-bg").hide();
        if ($(".bg-content").height() > 100) {
            $(".bg-content").addClass("qa-bg-show");
            $(".shou-all-bg").show();
        }
        $(".shou-all-bg").click(function () {
            $(".bg-content").removeClass("qa-bg-show");
            $(this).hide();
        })
    }
</script>

</div>
</body>
</html>